package top.yuhaitao.core.controller;

import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import top.yuhaitao.core.controller.RequestModel.RequestUserCarModel;
import top.yuhaitao.core.mybatis.dbo.TUserIntentionCar;
import top.yuhaitao.core.mybatis.mapper.TUserIntentionCarMapper;

import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * car
 *
 * @author ht.yu
 */
@RestController
@RequestMapping("/carSell")
public class CarSellController {

    @Resource
    private TUserIntentionCarMapper tUserIntentionCarMapper;


    @RequestMapping("/submitSHCarsell")
    public Map<String, Object> submitSHCarsell(@RequestBody RequestUserCarModel requestUserCarModel) {
        TUserIntentionCar tUserIntentionCar = new TUserIntentionCar();
        tUserIntentionCar.setRealName(requestUserCarModel.getRealName());
        tUserIntentionCar.setMobile(requestUserCarModel.getMobile());
        tUserIntentionCar.setCompany(requestUserCarModel.getCompany());
        tUserIntentionCar.setCarType(requestUserCarModel.getCarType());
        tUserIntentionCar.setFinanProduct(requestUserCarModel.getFinanProd());
        if (!StringUtils.isEmpty(requestUserCarModel.getAddress())) {
            tUserIntentionCar.setAddress(requestUserCarModel.getAddress());
        }
        tUserIntentionCar.setMail(requestUserCarModel.getMail());
        Date date = new Date();
        tUserIntentionCar.setCreateTime(date);
        tUserIntentionCar.setUpdateTime(date);
        tUserIntentionCarMapper.insertSelective(tUserIntentionCar);
        Map<String, Object> map = new HashMap<>();
        map.put("retCode", "0000");
        map.put("retMsg", "执行成功");
        map.put("success", true);
        map.put("data", new Date());
        return map;
    }
}
